import Vue from "vue";
import VueRouter from "vue-router";

import Login from "../components/commons/Login.vue";
import Register from "../components/commons/Register.vue";
import ResetPassword from "../components/commons/ResetPassword.vue";
import GraduateMain from "../components/graduate/GraduateMain.vue";
import EnterpriseMain from "../components/enterprise/EnterpriseMain.vue";
import EnterpriseInfo from "../components/enterprise/EnterpriseInfo.vue";
import PositionRelease from "../components/enterprise/PositionRelease.vue";
import ViewPositing from "../components/enterprise/ViewPositing.vue";
import InterviewSkills from "../components/enterprise/InterviewSkills.vue";
import EnterImg from "../components/enterprise/EnterImg.vue";
import EnterpriseUser from "../components/enterprise/EnterpriseUser.vue";
import EnterpriseUpdate from "../components/enterprise/EnterpriseUpdate.vue";
import GraduateSearch from '../components/graduate/GraduateSearch.vue'
import GraduateContent from '../components/graduate/GraduateContent.vue'
import GraduateDisplay from '../components/graduate/GraduateDisplay.vue'
import GraduatePreach from '../components/graduate/GraduatePreach.vue'
import GraduateCompany from '../components/graduate/GraduateCompany.vue'
import GraduateExperience from '../components/graduate/GraduateExperience.vue'
import RecommendPosition from '../components/recommend/RecommendPosition.vue'
import GraduateInfo from '../components/graduate/GraduateInfo.vue'
import Resume from '../components/resume/Resume.vue'
import GraduateDelivery from '../components/graduate/GraduateDelivery.vue'
import GraduateUpdatePassword from '../components/graduate/GraduateUpdatePassword.vue'
import EnterprisePropagandaMeeting from '../components/enterprise/EnterprisePropagandaMeeting.vue'
import GraduatePosition from '../components/graduate/GraduatePosition.vue'
import GraduateAppointment from '../components/graduate/GraduateAppointment.vue'
import EnterpriseAppointment from '../components/enterprise/EnterpriseAppointment.vue'
import AdminMain from '../components/admin/AdminMain.vue'
import GraduateManager from '../components/admin/GraduateManager.vue'
import EnterpriserManager from '../components/admin/EnterpriserManager.vue'
import EnterpriseManager from '../components/admin/EnterpriseManager.vue'
import PositionManager from '../components/admin/PositionManager.vue'
import ChartManager from '../components/admin/ChartManager.vue'
Vue.use(VueRouter);
// 路由规则
var router = new VueRouter({
  routes: [{
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login",
      component: Login,
    },
    {
      path: "/register",
      component: Register,
    },
    {
      path: "/reset",
      component: ResetPassword,
    },
    {
      path: "/gradmain",
      component: GraduateMain,
    },
    {
      path: "/entermain",
      component: EnterpriseMain,
      redirect: "/entermain/enterimg",
      children: [{
          path: "enterpriseinfo",
          component: EnterpriseInfo,
        },
        {
          path: "positionrelease",
          component: PositionRelease,
        },
        {
          path: "viewpositing",
          component: ViewPositing,
        },
        {
          path: "interviewskills",
          component: InterviewSkills,
        },
        {
          path: "enterimg",
          component: EnterImg,
        },
        {
          path: "entermeeting",
          component: EnterprisePropagandaMeeting,
        },
        {
          path: 'enterpriseappoint',
          component: EnterpriseAppointment
        }
      ],
    },
    {
      path: "/enterpriseuser",
      component: EnterpriseUser,
    },
    {
      path: "/enterpriseupdate",
      component: EnterpriseUpdate,
    },
    {
      path: '/graduatesearch',
      component: GraduateSearch
    },
    {
      path: '/graduatecontent',
      component: GraduateContent
    },
    {
      path: '/graduatedisplay',
      component: GraduateDisplay,
    },
    {
      path: '/graduatepreach',
      component: GraduatePreach
    },
    {
      path: '/graduatecompany',
      component: GraduateCompany
    },
    {
      path: '/graduateexperience',
      component: GraduateExperience
    },
    {
      path: '/recommendposition',
      component: RecommendPosition
    },
    {
      path: '/graduateinfo',
      component: GraduateInfo
    },
    {
      path: '/resume',
      component: Resume
    },
    {
      path: '/graduatedelivery',
      component: GraduateDelivery
    },
    {
      path: '/graduateupdate',
      component: GraduateUpdatePassword
    },
    {
      path: '/graduateposition/:ename',
      name: 'graduatePosition',
      component: GraduatePosition
    },
    {
      path: '/gradappointment',
      component: GraduateAppointment
    },
    {
      path: '/adminmain',
      component: AdminMain,
      redirect:'/adminmain/graduatemanager',
      children: [{
          path: 'graduatemanager',
          component: GraduateManager
        },
        {
          path:'enterprisermanager',
          component:EnterpriserManager
        },
        {
          path:'enterprisemanager',
          component:EnterpriseManager
        },
        {
          path:'positionmanager',
          component:PositionManager
        },
        {
          path:'chartmanager',
          component:ChartManager
        }
      ]
    }
  ],
});

// 导航守卫
// router.beforeEach(function (to, from, next) {
//     // to表示将要访问的路由对象
//     // from表示将要离开的路由对象
//     // next表示放行
//     if (to.path === '/main') {
//         var token = localStorage.getItem('token');
//         if (token) {
//             next()
//         } else {
//             next('/login')
//         }
//     } else {
//         next()
//     }
// })
export default router;